{extend name="index/base" /}
{block name="main"}
<script type="text/javascript" charset="utf-8" src="/static/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/static/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript" charset="utf-8" src="/static/ueditor/lang/zh-cn/zh-cn.js"></script>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 15px;">
    <legend>添加信息</legend>
</fieldset>
<form class="layui-form" action="{:url('save')}" method="post">
    <div class="layui-form-item">
        <label class="layui-form-label">标题</label>
        <div class="layui-input-block">
            <input type="text" name="title" id="title" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">英文名称</label>
        <div class="layui-input-block">
            <input type="text" name="ename" id="ename" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">所属分类</label>
        <div class="layui-input-block">
            <select name="type_id" lay-verify="required">
                <option value="">无上级</option>
                {:tree_to_select($category_list)}
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">栏目关键字</label>
        <div class="layui-input-block">
            <input type="text" name="keyword" id="keyword" required  lay-verify="required" placeholder="栏目关键字" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">栏目描述</label>
        <div class="layui-input-block">
            <textarea name="description" id="description" placeholder="栏目描述" class="layui-textarea"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">栏目图片</label>
        <div class="layui-input-block">
            <div class="layui-upload">
                <button type="button" class="layui-btn" id="test1">上传图片</button>
                <div class="layui-upload-list">
                    <img class="layui-upload-img" id="upload_pic" width="100px">
                    <input type="hidden" name="pic" id="pic" value="">
                    <p id="demoText"></p>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">详细内容</label>
        <div class="layui-input-block">
            <script id="editor_content" type="text/plain"  name="content"></script>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
{load href="/static/js/jquery-1.10.2.min.js"/}
<script>
    //Demo
    layui.use('form', function(){
        var form = layui.form;
        //监听提交

    });
</script>
<script>
    layui.use('upload', function(){
        var upload = layui.upload;
        //执行实例
        var uploadInst = upload.render({
            elem: '#test1' //绑定元素
            ,url: "{:url('File/upload')}" //上传接口
            ,done: function(res){
                //上传完毕回调
                layer.msg(res.msg);
                $('#upload_pic').attr('src',res.data);
                $('#pic').val(res.data);
            }
            ,error: function(){
                //请求异常回调
            }
        });
    });
</script>
<script>
    //注意：选项卡 依赖 element 模块，否则无法进行功能性操作
    layui.use('element', function(){
        var element = layui.element;

        //…
    });
</script>
<script type="text/javascript">
    //实例化编辑器
    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
    var ue = UE.getEditor('editor_content',{initialFrameWidth:'100%',initialFrameHeight:550});
</script>
{/block}